package com.demo.auth.service.remote.impl;

import com.demo.auth.service.remote.DispatchRemoteAuthUserMenuService;
import com.demo.common.base.constant.SysConstant;
import com.demo.common.base.pojo.JsonRes;
import com.demo.user.remote.RemoteAuthUserMenuService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @author DayDayUp
 * create on 2023-08-16
 **/
@Service
public class DispatchRemoteAuthUserMenuServiceImpl implements DispatchRemoteAuthUserMenuService {

    @Resource
    private RemoteAuthUserMenuService remoteAuthUserMenuService;

    /**
     * 获取用户权限
     * @param username 用户名
     * @return List<String>
     */
    @Override
    public List<String> getButtonListByUsername(String username){
        JsonRes<List<String>> jsonRes = remoteAuthUserMenuService.getButtonListByUsername(username);
        if (Objects.isNull(jsonRes) || !Objects.equals(SysConstant.SUCCESS, jsonRes.getStatus())) {
            return Collections.emptyList();
        }
        return jsonRes.getData();
    }
}
